// import * as request from '../utils/http-base/request'
// import { createGETParams } from '../utils/http-base/utils'
import axios from '@/libs/api.request'

export class SysAreaApi {
  static get (path, params = {}) {
    return request.get(path, createGETParams(params))
  }

  static post (path, params = {}) {
    return request.post(path, params)
  }

  // 获取所有省份
  static getProvince () {
    // return SysAreaApi.get('/api/SysArea/GetProvince')
    return axios.request({
      url: '/SysArea/GetProvince',
      method: 'get',
      enctype: 'multipart/form-data'
    })
  }

  // 获取目标省份下的所有城市
  static getCity (parentId) {
    // return SysAreaApi.get('/api/SysArea/GetCity', {parentId})
    return axios.request({
      url: '/SysArea/GetCity',
      method: 'get',
      params: { parentId: parentId },
      enctype: 'multipart/form-data'
    })
  }

  // 获取目标城市下的所有区县
  static getArea (parentId) {
    // return SysAreaApi.get('/api/SysArea/GetArea', {parentId})
    return axios.request({
      url: '/SysArea/GetArea',
      method: 'get',
      params: { parentId: parentId },
      enctype: 'multipart/form-data'
    })
  }

  // 获取中国所有城市树
  static getAreaTree (parentId) {
    return axios.request({
      url: '/SysArea/GetAreaTree',
      method: 'get',
      params: { parentId: parentId },
      enctype: 'multipart/form-data'
    })
  }
}
